file=open('./1.txt','r',encoding='utf-8')
print(file.read())#文件读取
file.close()#关闭文件

#写文件操作
file2=open('./1.txt','w',encoding='utf-8')
file2.write('hello world')
file2.close()

# # a模式追加不覆盖原本内容
# file3=open('./1.txt','a',encoding='utf-8')
# file3.write('\nhello2222')
# file3.close()

# with open('./5.txt','r',encoding='utf-8') as file4:
#     print(file4.read(3))
#     while True:
#         line = file4.readline()
#         if not line:
#             break
#         print(line)

# with open('./5.txt','r',encoding='utf-8') as file4:
#     print(file4.readlines())
#
# with open('./5.txt','a',encoding='utf-8') as file4:
#     str4 = '\nhello world4'
#     file4.write(str4)
#     list4=['\nhello world5','hello world6','hello world7']
#     file4.writelines(list4)

print("----------------------")
# #二进制文件拷贝
# with open('./1.png','rb') as file:
#     with open('./2.png','wb') as file2:
#         while True:
#             data=file2.read(1024)
#             if not data:
#                 break
#             file2.write(data)

with open('./1.txt','r',encoding='utf-8') as file:
    print(file.tell())
    line = file.read(3)
    print(file.tell())

# os.remove('./1.png')
# os.remove('./4442.jpg')
# os.rename('./1.png','./4442.jpg')
# os.mkdir("test1")
# os.mkdir("test2")
# os.rmdir("test2")
print(os.getcwd())
print(os.listdir())
